﻿using System;
using System.Collections.Generic;
using Gameplay.PVE.Utils;
using UnityEngine;
using XLua;
using Yoozoo.Framework.Core;

namespace Gameplay.PVE.Survivor
{
    public class SkillConfig
    {
        public int id;
        public int type;
        public List<int> value;
        public List<int> child_skills;
        public int search_sort;
        public int search_type;
        public int search_change_type;
        public Dictionary<string, float> param;
        public List<Vector3Int> bullets;
        public List<Vector3Int> effects;
        public List<Vector2Int> sound_frame;
        public List<Vector3Int> special_events;
        public List<string> sound_name;

        public float storage_time;
        public float shape_time;
        public int shape_type;
        public float shape_fix;
        public List<float> shape_params;
        public float cast_time;
        public float recover_time;
        public string action_name;
        public string storage_action_name;

        public float cast_range;
        
        //普攻用
        public int ammo_count;
        public float reload_time;
        public float reload_time_auto;
        public List<float> shoot_interval;
        public int shoot_bullet_count;

        public int passive_trigger_type;
        public List<int> passive_trigger_value;

        public int add_energy;
        public int follow_target;
        public float shape_delay_time;
        
        public float GetParam(string key)
        {
            if(param != null && param.TryGetValue(key,out var value))
            {
                return value;
            }
            return 0;
        }
    }
    
    public partial class BattleConfigManager
    {
        private Dictionary<int, SkillConfig> skillMap;
        public SkillConfig GetSkillConfig(int id)
        {
            if (skillMap.TryGetValue(id,out var config))
            {
                return config;
            }
            UnityEngine.Debug.LogError("技能配置找不到" + id);
            return null;
        }
        public static void PreloadSkillConfig(LuaTable table)
        {
            PveUtils.PreloadRpgConfig(table,ref Instance.skillMap);
        }
    }
}
